package com.yanqu.road.server.cmd.kuang;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.kuang.Kuang;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.kuang.KuangModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_KUANG_GIVE_UP_CHOOSE_EQUIPMENT, desc = "放弃选装备")
public class KuangGiveUpChooseEquipmentCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        Kuang.KuangGiveUpChooseEquipmentReqMsg reqMsg = Kuang.KuangGiveUpChooseEquipmentReqMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(KuangModule.class).giveUpChooseEquipment();
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            Kuang.KuangGiveUpChooseEquipmentRespMsg.Builder respMsg = Kuang.KuangGiveUpChooseEquipmentRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_KUANG_GIVE_UP_CHOOSE_EQUIPMENT, respMsg);
        }
    }
}
